<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>CMS Manager system</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/assets/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/assets/jquery-easyui-1.4.2/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/assets/jquery-easyui-1.4.2/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/assets/css/easyui.icon.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/jquery-easyui-1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/jquery.js/jquery.json.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/jquery.js/jquery.fw.ext.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/easyui.js/easyui.ext.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/js/MD5.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/assets/js/message.js"></script>
<script type="text/javascript">

	$(function() {
		var loginFun = function() {
			$('#loginBtn').linkbutton('disable');
			var password = $.trim($('#pwd').val());
			var username = $.trim($('#loginname').val());
			var data = {password:faultylabs.MD5(password),username:username};
			$.post('login.do', data, function(result) {
				if (result.success) {
					
					if(result.message > 6)
					{
						if(result.message == 8)
						{
							location.replace('swindex.jsp');
						}
						else
						{
							location.replace('login.jsp');
						}
					
					}
					else 
					{
						location.replace('archive.jsp');
					}
					
					
				} else {
					$.messager.alert('提示', result.errorMsg, 'error', function() {
						$('#loginBtn').linkbutton('enable');
					});
				}
			}, 'json');
		}

		$('#loginDialog').show().dialog({
			modal : false,
			closable : false,
			iconCls : 'ext-icon-lock_open',
			buttons : [ {
				id : 'loginBtn',
				text : '系统登录',
				handler : function() {
					loginFun();
				}
			} ],
			onOpen : function() {
				$('form :input:first').focus();
				$('form :input').keyup(function(event) {
					if (event.keyCode == 13) {
						loginFun();
					}
				});
			}
		});

	});
</script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
	<div id="loginDialog" title="系统登录" style="display: none; width: 350px; height: 150px; overflow: hidden;">
		<form method="post" class="form">
			<table class="table" style="width: 100%; height: 100%;">
				<tr>
					<th width="50">登录名</th>
					<td><input id="loginname" name="loginname" class="easyui-validatebox  textbox" value="admin" data-options="required:true" style="height: 22px;" /></td>
				</tr>
				<tr>
					<th>密码</th>
					<td><input id="pwd" name="pwd" type="password" class="easyui-validatebox  textbox" value="admin" data-options="required:true" style="height: 22px;" /></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>